package com.goods.controller.business;

import com.goods.business.service.SupplierService;
import com.goods.common.model.business.Supplier;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.SupplierVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "业务管理-物资来源")
@RestController
@RequestMapping("/business/supplier")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;

    @ApiOperation("分页查询物资来源")
    @GetMapping("/findSupplierList")
    public ResponseBean<PageVO<SupplierVO>> findSupplierList(
                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                         @RequestParam(value = "pageSize", defaultValue = "7") Integer pageSize,
                                          SupplierVO supplierVO){
        PageVO<SupplierVO> supplierVOPageVO = supplierService.findSupplierList(pageNum,pageSize,supplierVO);
        return ResponseBean.success(supplierVOPageVO);
    }
    @ApiOperation("物资来源新增")
    @PostMapping("/add")
    public ResponseBean add(@RequestBody SupplierVO supplierVO){
        supplierService.add(supplierVO);
        return ResponseBean.success("添加成功");
    }
    @ApiOperation("修改回显")
    @GetMapping("/edit/{id}")
    public ResponseBean edit(@PathVariable Long id){
        SupplierVO SupplierEdit = supplierService.edit(id);
        return ResponseBean.success(SupplierEdit);
    }
    @ApiOperation("修改确认")
    @PutMapping("/update/{id}")
    public ResponseBean update(@PathVariable Long id,@RequestBody SupplierVO supplierVO){
        return ResponseBean.success(supplierService.update(id,supplierVO));
    }
    @ApiOperation("删除")
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        return ResponseBean.success(supplierService.delete(id));
    }


}
